.TH E1432_GET_RAW_TACHS 3 E1432
.SH NAME
.nf
e1432_get_raw_tachs \- Read raw tach time data from a tachometer channel
.fi
.IX e1432_get_raw_tachs(3) 3
.SH SYNOPSIS
.cS
SHORTSIZ16 e1432_get_raw_tachs(E1432ID hw, SHORTSIZ16 ID,
                               unsigned long *buffer,
                               LONGSIZ32 size, LONGSIZ32 *actualCount)
.cE
.SH DESCRIPTION
\fIe1432_get_raw_tachs\fR returns a block of raw tach times into the buffer
pointed to by \fIbuffer\fR.  When the tach buffer on the E1432 is more than
half full the \fBE1432_IRQ_TACHS_AVAIL\fR bit in the
\fBE1432_IRQ_STATUS2_REG\fR register is set.  This bit can be polled or
interrupted on to know when to get the tach times

\fBNOTE:\fR This status bit will be set when \fBeither\fR tach channel's
buffer is over half full; so if both tach channels are active, the
\fIe1432_get_raw_tachs\fR must be called for both to clear this bit.  If
a second tach channel's tach times are not going to be read, then this 
channel should be made to be inactive with \fIe1432_set_active\fR.

\fIhw\fR must be the result of a successful call to
\fIe1432_assign_channel_numbers\fR, and specifies the group of
hardware to talk to.

\fIID\fR must be the ID of a single tachometer channel.

\fIbuffer\fR is a pointer to the array for returned data. 

\fIsize\fR is the size, in data points, of \fIbuffer\fR.  

\fBNote:\fR always make this size less than or equal to the actual allocated
memory for \fIbuffer\fR or the function may overrun your \fIbuffer\fR.

\fIactualCount\fR is a pointer to a long integer.  It is set to the
actual number of raw tach times transferred into \fIbuffer\fR.  It will
always be less than or equal to \fIsize\fR and may be zero, if no new
tach times were accumulated, or there has been an overflow in the 
tach buffer internal to the tach daughter card.  A tach overflow can be 
determined by a set \fBE1432_STATUS2_TACH_OVERFLOW\fR bit in the 
\fBE1432_IRQ_STATUS2_REG\fR register.  

\fBNOTE:\fR If there has been a tach overflow, there
still will be up to \fBE1432_TACH_RAW_SIZE\fR tach edge times stored in the
module's raw tach buffer that are available for internal processing
(i.e. order track arm points); so the \fBE1432_STATUS2_TACH_OVERFLOW\fR
measurement error is not returned by the \fIe1432_block_available\fR function
until all the stored tach edges are processed and the input data associated
with the are transferred to the host.

Raw tach times are just latched values of a 32 bit counter driven by a
tachometer clock.  The frequency of this clock is obtained by a call to
\fIe1432_get_tach_clock_freq\fR.  The following snipet of code shows how to
convert raw times into seconds, accounting for tach counter rollover:

.cS
        SHORTSIZ16 error, count;
        unsigned long buffer[BUF_SIZE];
        double tachTimes[BUF_SIZE];
	long tachTimeLast = 0;
	float tachFreq;
	double tachTimeOffset = 0.0, tachTimeStep;

        e1432_get_tach_clock_freq(hw, ID, &tachFreq);
	tachTimeStep = 1.0 / (double)tachFreq;

	error = e1432_get_raw_tachs(hw, ID, buffer, BUF_SIZE, &count);
	if(error) {
	    printf("e1432_get_raw_tachs returned error = %d\n", error);
	    exit(-1);
   	}

	/* convert raw tach times to seconds */
	for(i = 0; i < count; i++)
	{
	    if(buf[i] < tachTimeLast)	/* tach counter rollover has occured */
	    {
		tachTimeOffset += E1432_TACH_WRAP_COUNT * tachTimeStep;
	    }
	    tachTimeLast = buf[i];
	    tachTimes[i] = tachTimeOffset + (double)buf[i] * tachTimeStep;
	}
.cE

\fBNOTE:  Once this function is called the first time either it or the function
\fIe1432_send_tachs\fB must be called 
regularly to read tach values out of the module. If tach times are not read
out often enough, a tach buffer overflow
will happen, which will overwrite the internal tach buffer and cause
\fIe1432_block_available\fB to return ERR1432_TACH_BUFFER_OVERFLOW\fR.

.SH "RESET VALUE"
Not applicable.
.SH "RETURN VALUE"
Return 0 if successful, a (negative) error number otherwise.
.SH "SEE ALSO"
.na
e1432_get_scale, e1432_set_append_status, e1432_set_data_size,
e1432_set_data_port, e1432_send_tachs.
.ad
